package cn.formaggie.controller.manage;

import cn.formaggie.entity.model.roleandpermission.Permission;
import cn.formaggie.entity.model.roleandpermission.Worker;
import cn.formaggie.service.face.BackManageService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/back")
public class BackManageController {

    @Autowired
    private BackManageService backManageService;

    @RequiresAuthentication
    @RequestMapping("/manage")
    public String manager(HttpSession session,Model model){
        Worker worker= (Worker) session.getAttribute("worker");
        Map<String,List<Permission>> typeAndPer=backManageService.getPermissionsWithTypeByRoleId(worker.getRole().getId());
        model.addAttribute("mainPage","/WEB-INF/page/forepage/carousel.jsp");
        session.setAttribute("typeAndPers",typeAndPer);
        return "/backpage/backTemp";
    }


}
